home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagn_r.zip / PRINTING.SWG / 0012_PRINTER6.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  1KB  |  47 lines

  1. {
  2. I am writing a Program that Uses the Printer to (whatelse?) print
  3. out a report.  Now, the problem that I am having is that the Printer
  4. Function in TP 6.0 (ie Writeln (lst,'BLA BLA BLA');) Dosn't
  5. check For errors (if the Printer is not on, or is not online)
  6.  
  7.  You can determine the Various states of the Printer With Intr 17H -
  8.  Function 02H.  The value returned in AH will be:
  9.  
  10.          bit   if set
  11.            0 - Printer timed out
  12.            1 - unused
  13.            2 - unused
  14.            3 - i/o error
  15.            4 - Printer selected
  16.            5 - out of paper
  17.            6 - Printer acknowledge
  18.            7 - Printer not busy
  19.  
  20.  For example:
  21. }
  22. Function PrinterReady : Boolean;
  23. Var
  24.   reg : Registers;
  25.   Status : Byte;
  26.  
  27. begin
  28.   reg.AH := $02;
  29.   reg.DX := $00;  {..0=LPT1, 1=LPT2, etc }
  30.   intr($17,reg);
  31.  
  32.   Status := reg.AH and $41;  {..isolate bits 0,3,5 }
  33.   if Status <> 0 then
  34.     PrinterReady := False
  35.   else
  36.     PrinterReady := True;
  37. end;
  38.  
  39. {
  40. basicaly I need something that weill check and give out the
  41. NB>famous line ('Printer not Ready (A)bort (R)etry')
  42.  
  43. The way I've handled this in the past is to check PrinterReady beFore
  44. each Write/WriteLn statement (not very eloquant).  A better way to do
  45. this might be to hook it to an interrupt, checking the status every few
  46. seconds.
  47. }